package com.pzr.demo.web.controller.test.listener;

import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.delegate.TaskListener;

public class MyExecutionListener implements ExecutionListener, TaskListener {

	/**
	 * 
	 * @time 2017-1-9
	 * 
	 * @author Administrator
	 * 
	 */
	private static final long serialVersionUID = 1846882754030846362L;

	// ExecutionListener类的实现
	@Override
	public void notify(DelegateExecution execution) throws Exception {
		String eventName = execution.getEventName();
		// start
		if ("start".equals(eventName)) {
			System.out.println("start=========");
		} else if ("end".equals(eventName)) {
			System.out.println("end=========");
		} else if ("take".equals(eventName)) {
			System.out.println("take=========");
		}
		System.out.println("==================");
	}

	// 实现TaskListener中的方法
	@Override
	public void notify(DelegateTask delegateTask) {
		//设置多人审批
//		task.addCandidateUser("4028821658f6ed580158f6f450030002");  
//        task.addCandidateUser("40288216594433e50159449be9580002");  
		String eventName = delegateTask.getEventName();
		if ("create".endsWith(eventName)) {
			System.out.println("create=========");
		} else if ("assignment".endsWith(eventName)) {
			System.out.println("assignment========");
		} else if ("complete".endsWith(eventName)) {
			System.out.println("complete===========");
//			delegateTask.setAssignee("胡二");
		} else if ("delete".endsWith(eventName)) {
			System.out.println("delete=============");
		}
	}
}
